home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / mathstud.zip / TRIU.M < prev    next >
Text File  |  1993-03-23  |  270b  |  15 lines

  1. function Y = triu(X,k)
  2. %Y=triu(X,k)
  3. %Upper triangle of X
  4.  
  5. %       S.Halevy 7/31/92
  6. %       Copyright (c) 1992 by the MathWizards
  7.  
  8. k=expr_sel(nargin==1,0,k);
  9. [m,n] = size(X);
  10. Y = zeros(m,n);
  11. for j = max(1,1+k):n
  12.    i = 1:min(m,j-k);
  13.    Y(i,j) = X(i,j);
  14. end
  15.